﻿using GalaSoft.MvvmLight;
using ERTesting.Model.Config;

namespace ERTesting.Gui.ViewModel.Config
{
    /// <summary>
    /// This class contains properties that a View can data bind to.
    /// <para>
    /// Use the <strong>mvvminpc</strong> snippet to add bindable properties to this ViewModel.
    /// </para>
    /// <para>
    /// You can also use Blend to data bind with the tool's support.
    /// </para>
    /// <para>
    /// See http://www.galasoft.ch/mvvm/getstarted
    /// </para>
    /// </summary>
    public class TestParameterViewModel : ViewModelBase
    {

        #region Public Properties

        public TestParameter Parameter { get; private set; }

        /// <summary>
        /// The <see cref="Range" /> property's name.
        /// </summary>
        public const string RangePropertyName = "Range";        

        /// <summary>
        /// Gets the Range property.
        /// Changes to that property's value raise the PropertyChanged event. 
        /// </summary>
        public string Range
        {
            get
            {
                return Parameter.Range;
            }

            set
            {
                if ( Parameter.Range == value)
                {
                    return;
                }
                
                 Parameter.Range = value;

                // Update bindings, no broadcast
                RaisePropertyChanged(RangePropertyName);

            }
        }

        /// <summary>
        /// The <see cref="Value" /> property's name.
        /// </summary>
        public const string ValuePropertyName = "Value";

        /// <summary>
        /// Gets the Value property.
        /// Changes to that property's value raise the PropertyChanged event. 
        /// </summary>
        public string Value
        {
            get
            {
                return Parameter.Value;
            }

            set
            {
                if (Parameter.Value == value)
                {
                    return;
                }

                Parameter.Value = value;

                // Update bindings, no broadcast
                RaisePropertyChanged(ValuePropertyName);
            }
        }

        #endregion Public Properties


        #region Constructors

        /// <summary>
        /// Initializes a new instance of the TestParameterViewModel class.
        /// </summary>
        public TestParameterViewModel(TestParameter parameter)
        {
            Parameter = parameter;
        }

        #endregion Constructors

        ////public override void Cleanup()
        ////{
        ////    // Clean own resources if needed

        ////    base.Cleanup();
        ////}
    }
}